package org.goobs.utils;

public class Pair <E, F>{

	private E e;
	private F f;
	
	public Pair(E e, F f){
		this.e = e;
		this.f = f;
	}
	
	public E car(){
		return e;
	}
	
	public F cdr(){
		return f;
	}
	
	public void setCar(E car){
		this.e = car;
	}
	
	public void setCdr(F cdr){
		this.f = cdr;
	}
	
	@SuppressWarnings("unchecked")
	public boolean equals(Object o){
		if(o instanceof Pair){
			return e.equals(((Pair) o).e) && f.equals(((Pair) o).f);
		}
		return false;
	}
	
	public int hashCode(){
		return e.hashCode() + f.hashCode();
	}
	
	public String toString(){
		StringBuilder b = new StringBuilder();
		b.append("( ").append(e).append(" , ").append(f).append(")");
		return b.toString();
	}
}
